package com.ssd.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ssd.api.user.UserApi;
import com.ssd.entity.NodeEntity;
import com.ssd.mapper.NodeDao;
import com.ssd.service.NodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class NodeServiceImpl extends ServiceImpl<NodeDao, NodeEntity> implements NodeService {

    @Autowired
    private NodeDao nodeDao;

    /**
     * 分页查询商品列表，支持模糊查询
     *
     * @param pageNum  当前页码
     * @param pageSize 每页大小
     * @return 分页的商品集合
     */
    @Override
    public Page<Map<String, Object>> getNodeList(int pageNum, int pageSize,Long regionId,String nodeName) {
        Page<Map<String, Object>> page = new Page<>(pageNum, pageSize);
        return nodeDao.selectNodeList(page,regionId,nodeName);
    }

    @Override
    public NodeEntity selectNodeById(Long id) {
        return nodeDao.selectById(id);
    }

    @Override
    public int insertNode(NodeEntity node) {
        return nodeDao.insert(node);
    }

    @Override
    public int updateNode(NodeEntity node) {
        return nodeDao.updateById(node);
    }

    @Override
    public int deleteNodeByNodeIds(Long[] nodeIds) {
        return nodeDao.deleteBatchIds(java.util.Arrays.asList(nodeIds));
    }
}